package cc.jinglupeng.kom.bean;

import cc.jinglupeng.kom.util.JsonUtil;

public class Result {

    private int status;
    private String message;
    private Object data;

    public static Result newFailedInstance(int status) {
        Result result = new Result();
        result.setStatus(status);
        return result;
    }

    public static Result newFailedInstance(int status, String message) {
        Result result = new Result();
        result.setStatus(status);
        result.setMessage(message);
        return result;
    }

    public static Result newSucceededInstance(Object data) {
        Result result = new Result();
        result.setData(data);
        result.setStatus(0);
        return result;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return JsonUtil.toJson(this);
    }
}
